package com.example.demo.Controller;

import com.example.demo.Entity.FriendChart;
import com.example.demo.Entity.HistoryVersion;
import com.example.demo.Service.FriendChartService;
import com.example.demo.Service.HistoryVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/historyVersion")
public class HistoryVersionController {
    @Autowired
    private HistoryVersionService historyVersionService;

    /** 插入版本信息 */
    @PostMapping("/insert")
    public void insert(@RequestBody HistoryVersion historyVersion){
        historyVersionService.insert(historyVersion);
    }

    /** 寻找一个笔记对应的所有版本信息 */
    @GetMapping("/find")
    public List<HistoryVersion> find(@RequestParam Integer noteId){
        return historyVersionService.select(noteId);
    }

    /** 删除一个笔记对应的所有版本信息 */
    @GetMapping("/delete")
    public void deleteFriendChat(@RequestParam Integer noteId){
        historyVersionService.delete(noteId);
    }
}
